apex-ruby 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/apex_ext/apex_src/include/apex/apex.h +2 -2
- data/ext/apex_ext/apex_src/src/apex.c +2 -2
- data/ext/apex_ext/apex_src/src/extensions/ial.c +164 -4
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.c +7 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/config.h +38 -0
- data/lib/apex/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7293b4955edf88c3f7e4c94d8b53daf6e951100a954732ed6d4ec39d42e8c27d
|
|
4
|
+
data.tar.gz: 8e8c7770701a66d0ce072f9f19f4fe8e02a8d3b46d7a53d0837cee391089ec5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eddc7cc1d61ff37d0e817c5329ca446a9d7b509c312ad6c74207bcde526e58c7896df3570d4ce395989782bf72a85ed103172b787e8b6296f583569639b4645a
|
|
7
|
+
data.tar.gz: 44e77a363487d9b97fafb8b98916d1879e6208c308e7585a368053002c81a829bfa11ecb005c25c55c8cfb4f2d6574444eea54eb01676014bde032c2679a3385
|
|
@@ -21,8 +21,8 @@ typedef struct cmark_node cmark_node;
|
|
|
21
21
|
|
|
22
22
|
#define APEX_VERSION_MAJOR 1
|
|
23
23
|
#define APEX_VERSION_MINOR 1
|
|
24
|
-
#define APEX_VERSION_PATCH
|
|
25
|
-
#define APEX_VERSION_STRING "1.1.
|
|
24
|
+
#define APEX_VERSION_PATCH 35
|
|
25
|
+
#define APEX_VERSION_STRING "1.1.35"
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Processor compatibility modes
|
|
@@ -807,8 +807,8 @@ static char *apex_preprocess_autolinks(const char *text, const apex_options *opt
|
|
|
807
807
|
|
|
808
808
|
/* Then: check for reference link definitions: [id]: URL */
|
|
809
809
|
line_start = r;
|
|
810
|
-
/* Skip leading whitespace */
|
|
811
|
-
while (*line_start == ' ' || *line_start == '\t') {
|
|
810
|
+
/* Skip leading whitespace and blockquote markers */
|
|
811
|
+
while (*line_start == ' ' || *line_start == '\t' || *line_start == '>') {
|
|
812
812
|
line_start++;
|
|
813
813
|
}
|
|
814
814
|
/* Check for [id]: pattern */
|
|
@@ -2781,6 +2781,130 @@ static bool looks_like_attr_key_equals(const char *p, const char *end) {
|
|
|
2781
2781
|
return (p > key_start && p < end && *p == '=');
|
|
2782
2782
|
}
|
|
2783
2783
|
|
|
2784
|
+
static const char *ial_next_line(const char *p) {
|
|
2785
|
+
while (*p && *p != '\n' && *p != '\r') p++;
|
|
2786
|
+
if (*p == '\r' && p[1] == '\n') return p + 2;
|
|
2787
|
+
return *p ? p + 1 : p;
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
/* Length of a ``` or ~~~ fence run opening the line (after indentation and
|
|
2791
|
+
* blockquote markers), or 0 if the line is not a fence. */
|
|
2792
|
+
static size_t ial_fence_run(const char *line, char *fence_char, const char **after_run) {
|
|
2793
|
+
const char *p = line;
|
|
2794
|
+
while (*p == ' ' || *p == '\t' || *p == '>') p++;
|
|
2795
|
+
if (*p != '`' && *p != '~') return 0;
|
|
2796
|
+
char c = *p;
|
|
2797
|
+
const char *run = p;
|
|
2798
|
+
while (*p == c) p++;
|
|
2799
|
+
if (p - run < 3) return 0;
|
|
2800
|
+
*fence_char = c;
|
|
2801
|
+
*after_run = p;
|
|
2802
|
+
return (size_t)(p - run);
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
/**
|
|
2806
|
+
* Number of bytes at pos that are code (a closed fenced block starting at
|
|
2807
|
+
* this line, a code span, or an unmatched backtick run) and must be copied
|
|
2808
|
+
* through untouched. Returns 0 when pos does not start code.
|
|
2809
|
+
*/
|
|
2810
|
+
static size_t ial_code_region_len(const char *base, const char *pos) {
|
|
2811
|
+
bool line_start = (pos == base || pos[-1] == '\n' || pos[-1] == '\r');
|
|
2812
|
+
if (line_start) {
|
|
2813
|
+
char fence_char;
|
|
2814
|
+
const char *after;
|
|
2815
|
+
size_t open_len = ial_fence_run(pos, &fence_char, &after);
|
|
2816
|
+
if (open_len) {
|
|
2817
|
+
bool valid = true;
|
|
2818
|
+
if (fence_char == '`') {
|
|
2819
|
+
for (const char *q = after; *q && *q != '\n' && *q != '\r'; q++) {
|
|
2820
|
+
if (*q == '`') { valid = false; break; }
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
if (valid) {
|
|
2824
|
+
const char *line = ial_next_line(pos);
|
|
2825
|
+
while (*line) {
|
|
2826
|
+
char close_char;
|
|
2827
|
+
const char *close_after;
|
|
2828
|
+
size_t close_len = ial_fence_run(line, &close_char, &close_after);
|
|
2829
|
+
if (close_len >= open_len && close_char == fence_char) {
|
|
2830
|
+
while (*close_after == ' ' || *close_after == '\t') close_after++;
|
|
2831
|
+
if (!*close_after || *close_after == '\n' || *close_after == '\r') {
|
|
2832
|
+
return (size_t)(ial_next_line(line) - pos);
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
line = ial_next_line(line);
|
|
2836
|
+
}
|
|
2837
|
+
/* Unclosed fence: protect only the opening line */
|
|
2838
|
+
return (size_t)(ial_next_line(pos) - pos);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
if (*pos != '`') return 0;
|
|
2844
|
+
|
|
2845
|
+
size_t backslashes = 0;
|
|
2846
|
+
for (const char *b = pos; b > base && b[-1] == '\\'; b--) backslashes++;
|
|
2847
|
+
if (backslashes % 2) return 1;
|
|
2848
|
+
|
|
2849
|
+
const char *p = pos;
|
|
2850
|
+
while (*p == '`') p++;
|
|
2851
|
+
size_t open_len = (size_t)(p - pos);
|
|
2852
|
+
|
|
2853
|
+
/* Code spans may wrap lines but end at a blank line */
|
|
2854
|
+
while (*p) {
|
|
2855
|
+
if (*p == '\n' || *p == '\r') {
|
|
2856
|
+
const char *next = ial_next_line(p);
|
|
2857
|
+
const char *q = next;
|
|
2858
|
+
while (*q == ' ' || *q == '\t' || *q == '>') q++;
|
|
2859
|
+
if (!*q || *q == '\n' || *q == '\r') break;
|
|
2860
|
+
p = next;
|
|
2861
|
+
continue;
|
|
2862
|
+
}
|
|
2863
|
+
if (*p == '`') {
|
|
2864
|
+
const char *run = p;
|
|
2865
|
+
while (*p == '`') p++;
|
|
2866
|
+
if ((size_t)(p - run) == open_len) return (size_t)(p - pos);
|
|
2867
|
+
continue;
|
|
2868
|
+
}
|
|
2869
|
+
p++;
|
|
2870
|
+
}
|
|
2871
|
+
return open_len;
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
/* A reference definition label must open its line, after at most three
|
|
2875
|
+
* spaces of indentation (blockquote markers allowed). */
|
|
2876
|
+
static bool ial_at_definition_start(const char *base, const char *pos) {
|
|
2877
|
+
const char *p = pos;
|
|
2878
|
+
for (;;) {
|
|
2879
|
+
int spaces = 0;
|
|
2880
|
+
while (p > base && p[-1] == ' ') {
|
|
2881
|
+
p--;
|
|
2882
|
+
spaces++;
|
|
2883
|
+
}
|
|
2884
|
+
if (spaces > 3) return false;
|
|
2885
|
+
if (p == base || p[-1] == '\n' || p[-1] == '\r') return true;
|
|
2886
|
+
if (p[-1] != '>') return false;
|
|
2887
|
+
p--;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
static bool ial_append_verbatim(char **buf, char **write, size_t *remaining,
|
|
2892
|
+
const char *src, size_t len) {
|
|
2893
|
+
if (len >= *remaining) {
|
|
2894
|
+
size_t written = (size_t)(*write - *buf);
|
|
2895
|
+
size_t new_cap = (written + len + 1) * 2;
|
|
2896
|
+
char *grown = realloc(*buf, new_cap);
|
|
2897
|
+
if (!grown) return false;
|
|
2898
|
+
*buf = grown;
|
|
2899
|
+
*write = grown + written;
|
|
2900
|
+
*remaining = new_cap - written - 1;
|
|
2901
|
+
}
|
|
2902
|
+
memcpy(*write, src, len);
|
|
2903
|
+
*write += len;
|
|
2904
|
+
*remaining -= len;
|
|
2905
|
+
return true;
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2784
2908
|
/**
|
|
2785
2909
|
* Preprocess markdown to extract image attributes and URL-encode all link URLs
|
|
2786
2910
|
*/
|
|
@@ -2826,6 +2950,17 @@ char *apex_preprocess_image_attributes(const char *text, image_attr_entry **img_
|
|
|
2826
2950
|
int image_index = 0;
|
|
2827
2951
|
|
|
2828
2952
|
while (*read) {
|
|
2953
|
+
size_t code_len = ial_code_region_len(text, read);
|
|
2954
|
+
if (code_len) {
|
|
2955
|
+
if (!ial_append_verbatim(&output, &write, &remaining, read, code_len)) {
|
|
2956
|
+
free(output);
|
|
2957
|
+
apex_free_image_attributes(local_img_attrs);
|
|
2958
|
+
return NULL;
|
|
2959
|
+
}
|
|
2960
|
+
read += code_len;
|
|
2961
|
+
continue;
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2829
2964
|
/* Look for inline images:  */
|
|
2830
2965
|
if (*read == '!' && read[1] == '[') {
|
|
2831
2966
|
const char *img_start = read;
|
|
@@ -3244,7 +3379,7 @@ char *apex_preprocess_image_attributes(const char *text, image_attr_entry **img_
|
|
|
3244
3379
|
|
|
3245
3380
|
/* Look for reference-style link definitions: [ref]: url attributes */
|
|
3246
3381
|
/* Process to URL-encode URLs and extract image attributes if present */
|
|
3247
|
-
if (*read == '[') {
|
|
3382
|
+
if (*read == '[' && ial_at_definition_start(text, read)) {
|
|
3248
3383
|
const char *ref_start = read;
|
|
3249
3384
|
const char *ref_end = strchr(ref_start, ']');
|
|
3250
3385
|
if (ref_end && ref_end[1] == ':' && (ref_end[2] == ' ' || ref_end[2] == '\t')) {
|
|
@@ -4111,6 +4246,18 @@ char *apex_preprocess_image_attributes(const char *text, image_attr_entry **img_
|
|
|
4111
4246
|
bool made_expansions = false;
|
|
4112
4247
|
|
|
4113
4248
|
while (*read2) {
|
|
4249
|
+
size_t code_len2 = ial_code_region_len(output, read2);
|
|
4250
|
+
if (code_len2) {
|
|
4251
|
+
if (!ial_append_verbatim(&expanded_output, &write2, &remaining2, read2, code_len2)) {
|
|
4252
|
+
free(expanded_output);
|
|
4253
|
+
free(output);
|
|
4254
|
+
apex_free_image_attributes(local_img_attrs);
|
|
4255
|
+
return NULL;
|
|
4256
|
+
}
|
|
4257
|
+
read2 += code_len2;
|
|
4258
|
+
continue;
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4114
4261
|
/* Look for full, collapsed, and shortcut reference images. */
|
|
4115
4262
|
if (*read2 == '!' && read2[1] == '[') {
|
|
4116
4263
|
const char *img_start = read2;
|
|
@@ -4311,6 +4458,17 @@ char *apex_preprocess_image_attributes(const char *text, image_attr_entry **img_
|
|
|
4311
4458
|
size_t proc_remaining = strlen(output) * 2;
|
|
4312
4459
|
|
|
4313
4460
|
while (*proc_read) {
|
|
4461
|
+
size_t code_len3 = ial_code_region_len(output, proc_read);
|
|
4462
|
+
if (code_len3) {
|
|
4463
|
+
if (!ial_append_verbatim(&proc_output, &proc_write, &proc_remaining, proc_read, code_len3)) {
|
|
4464
|
+
free(proc_output);
|
|
4465
|
+
proc_output = NULL;
|
|
4466
|
+
break;
|
|
4467
|
+
}
|
|
4468
|
+
proc_read += code_len3;
|
|
4469
|
+
continue;
|
|
4470
|
+
}
|
|
4471
|
+
|
|
4314
4472
|
/* Look for inline images that were just expanded */
|
|
4315
4473
|
if (*proc_read == '!' && proc_read[1] == '[') {
|
|
4316
4474
|
const char *img_start = proc_read;
|
|
@@ -4446,9 +4604,11 @@ char *apex_preprocess_image_attributes(const char *text, image_attr_entry **img_
|
|
|
4446
4604
|
}
|
|
4447
4605
|
}
|
|
4448
4606
|
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4607
|
+
if (proc_output) {
|
|
4608
|
+
*proc_write = '\0';
|
|
4609
|
+
free(output);
|
|
4610
|
+
output = proc_output;
|
|
4611
|
+
}
|
|
4452
4612
|
}
|
|
4453
4613
|
}
|
|
4454
4614
|
}
|
|
@@ -158,6 +158,13 @@ static void replace_escaped_ltlt(cmark_mem *mem, cmark_strbuf *buf) {
|
|
|
158
158
|
bufsize_t len = buf->size;
|
|
159
159
|
unsigned char *ptr = buf->ptr;
|
|
160
160
|
cmark_strbuf out;
|
|
161
|
+
|
|
162
|
+
/* Too short to hold \<<. Returning early also matters for empty cells: the
|
|
163
|
+
loop would write nothing, leaving `out` allocated but never NUL-terminated,
|
|
164
|
+
and callers read the cell buffer as a C string. */
|
|
165
|
+
if (len < 3)
|
|
166
|
+
return;
|
|
167
|
+
|
|
161
168
|
cmark_strbuf_init(mem, &out, len + 1);
|
|
162
169
|
|
|
163
170
|
for (r = 0; r < len;) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#ifndef CMARK_CONFIG_H
|
|
2
|
+
#define CMARK_CONFIG_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#define HAVE_STDBOOL_H 1
|
|
9
|
+
|
|
10
|
+
#ifdef HAVE_STDBOOL_H
|
|
11
|
+
#include <stdbool.h>
|
|
12
|
+
#elif !defined(__cplusplus)
|
|
13
|
+
typedef char bool;
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#define HAVE___BUILTIN_EXPECT 1
|
|
17
|
+
|
|
18
|
+
#define HAVE___ATTRIBUTE__ 1
|
|
19
|
+
|
|
20
|
+
#ifdef HAVE___ATTRIBUTE__
|
|
21
|
+
#define CMARK_ATTRIBUTE(list) __attribute__ (list)
|
|
22
|
+
#else
|
|
23
|
+
#define CMARK_ATTRIBUTE(list)
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
#ifndef CMARK_INLINE
|
|
27
|
+
#if defined(_MSC_VER) && !defined(__cplusplus)
|
|
28
|
+
#define CMARK_INLINE __inline
|
|
29
|
+
#else
|
|
30
|
+
#define CMARK_INLINE inline
|
|
31
|
+
#endif
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif
|
data/lib/apex/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apex-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.33
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Terpstra
|
|
@@ -159,6 +159,7 @@ files:
|
|
|
159
159
|
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark_ctype.c
|
|
160
160
|
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark_ctype.h
|
|
161
161
|
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/commonmark.c
|
|
162
|
+
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/config.h
|
|
162
163
|
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/entities.inc
|
|
163
164
|
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/footnotes.c
|
|
164
165
|
- ext/apex_ext/apex_src/vendor/cmark-gfm/src/footnotes.h
|